package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description DishMapper.xml
 * @Author 王富贵
 * @Date 2024-10-06
 */
public interface DishMapper {

    @AutoFill(OperationType.INSERT)
    void sava(Dish dish);

    Page<DishVO> page(DishPageQueryDTO dto);

    void deleteByIds(List<Long> ids);

    Integer selectCountByIdsAndStatus(@Param("ids") List<Long> ids,
                                      @Param("status") Integer status);

    DishVO selectDishWithFlavor(Long dishId);

    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 动态条件查询菜品
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);

    /**
     * 根据套餐id查询菜品
     * @param setmealId
     * @return
     */
    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long setmealId);
}
